<?php
/**
 * Pages_AdminController
 * 
 * @author
 * @version 
 */
class News_IndexController extends Zend_Controller_Action {
	
	public function init() {
		$model = new News_Model_Item();
		$this->model = $model;
		Zen_Style::add(Zen_Theme::_('/css/news.css'));
	}
	
	public function blockAction() {
		$res = $this->model->getList(1,3);
		$this->view->res = $res;
	}
	
	public function indexAction() {
		$model = $this->model;
		$id = $this->_helper->checkParam('id',false,'Int','Int');
		if ( $id ) {
			Zen_Script::add( Zen_Theme::_('/js/jcarousellite.js')); 
			Zen_Script::add( Zen_Theme::_('/js/news.js'));
			Zen_Script::add('http://userapi.com/js/api/openapi.js?26' );
			$res = $model->getOne ( $id );
			$this->view->res = $res;
			$this->render ( 'one' );
		} else {
			$year = $this->_helper->checkParam('year',false,'Int','Int');
			$years = $model->getYears();
			$year = $model->getYear($year);
			$res = $model->getList(1,0,"YEAR(`date`)='".$year."'");
			$this->view->year=$year;
			$this->view->res = $res;
		}
	}

}
